import itertools

perms = list(map("".join, itertools.permutations('0123456789')))
for x in range(len(perms)):
	perms[x] = int(perms[x])
perms.sort()
print(perms[1000000-1])